using UnityEngine;

namespace FutureCorePlugin
{
    public class CanvasRootAdaptive : MonoBehaviour
    {
        private RectTransform rectTF;

        private void Awake()
        {
            rectTF = GetComponent<RectTransform>();
            Adaptive();
        }

#if UNITY_EDITOR
        private float currScreenHeight;
        private float currScreenWidth;

        private void Update()
        {
            if (currScreenHeight != Screen.height || currScreenWidth != Screen.width)
            {
                currScreenHeight = Screen.height;
                currScreenWidth = Screen.width;
                AdaptiveConst.CurrAspectRatio = (float)Screen.height / Screen.width;
                Adaptive();
            }
        }
#endif

        private void Adaptive()
        {
            if (rectTF == null) return;

            UIUtils.SetUIFullScreen(rectTF);
        }
    }
}